package com.heima.admin.job;

import com.heima.admin.feign.WemediaFeign;
import com.heima.admin.service.WemediaNewsAutoScanService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.log4j.Log4j2;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalTime;
import java.util.List;

/**
 * @作者 itcast
 * @创建日期 2020/9/28 10:28
 **/
@Component
@Slf4j
public class WemediaNewsAutoScanJob {

    @Autowired
    private WemediaNewsAutoScanService wemediaNewsAutoScanService;

    @Autowired
    private WemediaFeign wemediaFeign;

    /**
     * 每天0时执行一次任务
     * @param param
     * @return
     */
    @XxlJob("wemediaAutoScanJob")
    public ReturnT<String> newsAutoScanJob(String param) {
        log.info("自媒体文章审核调用任务执行开始 ....");
        List<Integer> releaseIdList = wemediaFeign.findRelease();

        if(releaseIdList!=null && !releaseIdList.isEmpty()){
            for (Integer id : releaseIdList) {
                wemediaNewsAutoScanService.autoScanByMediaNewsId(id);
            }
        }
        log.info("自媒体文章审核调度任务执行结束 ....");
        return ReturnT.SUCCESS;
    }
}
